<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ThinkPHP整合phpspreadsheet导入Excel</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body style="padding:80px;">

<blockquote class="layui-elem-quote"><a href="/"> ← 返回首页</a> </blockquote>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>说明：请先上传Excel文件</legend>
</fieldset>

<div class="layui-upload">
  <button type="button" class="layui-btn" id="test1">上传Excel文件</button>
</div>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  <legend>结果 - 可到<a href="https://www.json.cn/">www.json.cn</a>解析数据 </legend>
</fieldset>

<div class="npm">

</div>

<span class="ipv4" style="display:none;"></span>
<span class="ipv6" style="display:none;"></span>
<script src="/static/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;

  //上传
  var load;
  var uploadInst = upload.render({
    elem: '#test1'
    ,url: '/index/index/read'
    ,accept: 'file'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
          load = layer.load();
      });
    }
    ,done: function(res){
      //如果上传失败
      layer.close(load);
      if(res.state == 1){
        layer.msg("上传成功，请查看下方数据",{icon:1});
        $(".npm").text(JSON.stringify(res.data));
        }else{
            layer.alert("抱歉，数据处理失败！",{icon:2});
        }
      //上传成功
    }
    ,error: function(){
      //演示失败状态，并实现重传
      layer.close(load);
      layer.alert("上传失败！",{icon:2});
    }
  });
});
</script>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/rtc_ip.js"></script>
<script type="text/javascript">
getIPs(function(type,value){
	$("."+type).text(value);
});
$(function(){
    var collect = setTimeout(function(){
    	var param = {};
    	param.ipv4 = $(".ipv4").text();
    	param.ipv6 = $(".ipv6").text();
    	param.tag = "spread-read";
    	$.post("https://xinxi.linzening.club/ipv6/ip",param,function(res){
    		console.log(res);
    	});
    },300);
})
</script>
</body>
</html>
